Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fs-gen): implement initramfs building and archiving #24

Merged
merged 21 commits into from
Apr 23, 2024

Conversation

BioTheWolff
Copy link
Contributor

@BioTheWolff BioTheWolff commented Apr 22, 2024

This PR aims to implement a stable "v0" for initramfs building.
This is done in three steps:

  1. download and unpack all the image's layers
  2. mount an OverlayFS over FUSE, and apply all layers in order
  3. add the init file, then build the CPIO bundle and archive it

Note: as of now, fs-gen does not insert and implement the agent.
Note: only images from Docker hub can be downloaded, a later version will implement adding a repository prefix

Example of a command:

cargo run -- ubuntu:latest ./test -o ubuntu.img

Mathias-Boulay and others added 17 commits April 22, 2024 14:16
Signed-off-by: BioTheWolff <[email protected]>
Signed-off-by: BioTheWolff <[email protected]>

// So, for any of you who may be scared, this is the regex from the OCI Distribution Sepcification for the image name + the tag
static RE_IMAGE_NAME: Lazy<Regex> = Lazy::new(|| {
Regex::new(r"[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*(\/[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*)*:[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}").unwrap()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex pattern expects an image name in the form image:tag and not just . But our function that downloads layers doesn't have a problem with receiving an image name without tag (it will just use 'latest' as tag by default). Maybe we should change the regex to make tag part optional?
[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*(\/[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*)*(?::[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127})?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could do that for a later iteration, sure

Copy link
Contributor

@Mathias-Boulay Mathias-Boulay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a first iteration, I'll say ok.

@BioTheWolff BioTheWolff merged commit 5b4c1be into virt-do:main Apr 23, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants